<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/',     'IndexController@index');
Route::any('wechat',     'WechatController@serve');
Route::any('wxuser-info','WechatController@index')->middleware(['wechat.oauth:default,snsapi_userinfo']);
Route::prefix('zadmin')->namespace('Admin')->group(function(){
	Route::get('login',     'LoginController@login');
 	Route::any('logindo',   'LoginController@loginDo');
 	Route::middleware('checkAdmin')->group(function(){
 		Route::resource('task','TaskController');
		Route::resource('admins',	'AdminController');
		Route::resource('system',   'SystemController');				
		Route::resource('cate',		'CateController');
		Route::resource('role',		'RoleController');
		Route::resource('banner',	'BannerController');
		Route::resource('notice',	'NoticeController');
		Route::resource('spec',		'SpecController');
		Route::resource('coupon',	'CouponController');
		Route::resource('tag',		'TagController');
		Route::resource('customer-service','CustomerServiceController');
		//Route::resource('tensecond','TensecondController');
		Route::get('index',			'IndexController@index');
		Route::get('test',			'IndexController@test');
		Route::resource('menu',		'MenuController');
		Route::get('menu/permission/{id}','MenuController@menuPermission');
		//Route::resource('permission',	  'PermissionController');


		Route::prefix('users')->group(function(){
			Route::get('list',		'UserController@index');
			Route::post('update',	'Usercontroller@update');
			Route::get('show/{user_id}',     	'UserController@show');
			Route::get('coordinate/{user_id}',	'UserController@coordinate');
			
			Route::get('address/{user_id}',   'UserController@address');
			Route::get('envelope/{user_id}',  'UserController@envelope');
			Route::get('moneylog/{user_id}',  'Usercontroller@moneylog');
			Route::get('coupon/{user_id}',    'Usercontroller@coupon');
			Route::post('change-status',      'Usercontroller@changeStatus'); // 停用账号
		});

		
		


		Route::prefix('products')->group(function(){
			Route::get('add',         'ProductController@add');
			Route::get('edit',		  'ProductController@edit');
			Route::post('save',		  'ProductController@save');
			Route::post('update',	  'ProductController@update');
			Route::post('sale-status','ProductController@saleStatus');
			Route::get('change-rec','ProductController@changeRec');
			Route::delete('delete/{id}','ProductController@destroy');
			Route::get('thumb',			'ProductController@setThumb');

			Route::get('spec' ,         'ProductController@spec');
			Route::post('spec-save',    'ProductController@specSave');

			Route::get('img-delete',    'ProductController@imgDel');
			Route::get('/',             'ProductController@index');



		});

		Route::prefix('order')->group(function(){
			Route::get('detail/{order_id}','OrderController@detail');
			Route::get('confirm',  'OrderController@confirm');
			Route::get('reject',   'OrderController@reject');
			Route::post('send',    'OrderController@send');
			Route::get('complete', 'OrderController@complete');
			Route::get('export',   'OrderController@export');
			Route::get('/',		   'OrderController@index');
		});

		// 退款
		Route::resource('refunds',	  'OrderRefundController');

		Route::get('tplmsg/list','TplMsgController@index');


		Route::prefix('wechat')->group(function(){
			Route::get('wxuser/pull',  'WxuserController@pull');
			Route::get('wxuser/import',  'WxuserController@import');
			Route::post('wxuser/save-user','WxuserController@saveToUser');
			Route::resource('wxuser',  'WxuserController');
		});	

		Route::get('/','IndexController@dashboard');
	});
});

Route::prefix('h5')->group(function(){
	// 订单详情
	Route::get('order-info',     'IndexController@orderInfo');
	// 保存派工信息
	Route::post('order-dispatch','IndexController@orderDispatch');
	// 保存接单信息
	Route::post('order-accept',  'IndexController@orderAccept');
});

Route::prefix('mobile')->namespace('Mobile')->group(function(){
    Route::get('/','IndexController@index');


    Route::get('index','IndexController@index');
    //商品分类
    Route::get('class','CategoryController@index');
    //商品详情
    Route::resource('items','ItemController')->middleware(['wechat.oauth:snsapi_userinfo']);

    Route::resource('task','TaskController');
    //加/减收藏
    Route::post('favorite','ItemController@favorite')->middleware(['wechat.oauth:snsapi_userinfo']);

    //购物车
    Route::resource('carts','CartController')->middleware(['wechat.oauth:snsapi_userinfo']);
    //加购物车校验
    Route::post('cart-validate','CartController@cartValidate');

    //提交订单前
    Route::post('cart-confirm','CartController@cartConfirm');
    //个人中心
    Route::resource('homes','HomeController')->middleware(['wechat.oauth:snsapi_userinfo']);

    //收藏列表
    Route::get('star/{openid?}','HomeController@star')->middleware(['wechat.oauth:snsapi_userinfo']);

    //收货地址新增
    Route::get('address-create','UserAddressController@addressCreate');
    Route::post('address-store','UserAddressController@addressStore');



    //订单
    Route::resource('orders','OrderController')->middleware(['wechat.oauth:snsapi_userinfo']);
});
